

use "$data\Amenities\Diamond\replication\data\gmm_estimation_data", clear

label var wage0 "Non-College Wage"
label var wage1 "College Wage"
label var rentg "Monthly Gross Rent"
label var ln_col_ratio "Log College Employment Ratio"
label var lnstudent_teacher_ratio "Log Student Teacher Ratio"
label var lnstudent_spending "Log Edu Spending per Student"
label var lnest_pc5600 "Log Apparel Stores per 1000 Residents"
label var lnest_pc5800 "Log Eating and Drinking Places per 1000 Residents"
label var lnest_pc7830 "Log Movie Thearters per 1000 Residents"
label var lnprop "Log Property Crimes per 1000 Residents"
label var lnvio "Log Violent Crime per 1000 Residents"
label var lnaadt_IH "Log Avg Daily Traffic-Interstates"
label var lnaadt_MRU "Log Avg Daily Traffic-Major Roads"
label var lnbus "Log Bus Routers per capita"
label var lntrans "Log Public Transit Index"
label var lnmedian "Log EPA Air Quality Index"
label var lnpark "Log Gov Spending on Parks per capita"
label var lnunemp "Log Employment Rate"
label var lnpat "Log Patents per capita"
label var WRLURI_msa "Wharton Landuse Regulation Index"
label var unaval_msa "Pct Land Unavailable for Real Estate Development"

drop id
*Table 1
sum wage0 wage1 rentg  ln_col_ratio lnstudent_teacher_ratio  lnstudent_spending lnest_pc5600  lnest_pc5800  lnest_pc7830  lnprop lnvio  lnaadt_IH lnaadt_MRU lnbus lntrans lnmedian lnpark lnunemp lnpat if  bp==3
sum WRLURI_msa unaval_msa if year==3  & bp==3



*Table 3
foreach i in  patent_pc unemp_rate  median_aqi  aadt_IH aadt_MRU student_teacher_ratio student_spending parks_spending  est_pc5600 est_pc5800  est_pc7830  violent_rate prop_rate {
gen ln__`i'=ln(`i')
}

foreach i of varlist  ln__* lnbus_pc lntransit_pc {
gen d_`i'=s2.`i'

reg d_`i' d_ln_colratio if bp==3

}





//Table 4
pca dlnstudent_teacher_ratio dlnstudent_spending, comp(1)
predict school
pca  dlnest_pc5600  dlnest_pc5800  dlnest_pc7830 , comp(1) 
predict retail

pca dlnprop dlnvio, comp(1) 
predict crime

pca dlnaadt_IH dlnaadt_MRU dlnbus dln_trans, comp(1)
predict road


pca dlnmedian dlnpark, comp(1)
predict environment

pca dlnunemp dlnpat, comp(1) 
predict jobs


pca school  crime retail road environment jobs ,  comp(1) 
predict amen_index


//keep amen_index msa year pop_all
save "$temp/diamond_amenities", replace
